<?php
// Tim'Roster
// Copyright (c) 2011 Nicolas Nallet <aspgic2@gmail.com>
//
// This file is part of Tim'Roster.
//
// Tim'Roster is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Tim'Roster is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA



if ((isset($_POST['dbserver'])) && (isset($_POST['dbname']))
        && (isset($_POST['dbuser'])) && (isset($_POST['dbpassword']))){

    $roster_root_directory = substr(strstr(dirname($_SERVER['PHP_SELF']), '/install', true), 1);

    define('CHARACTERS','AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn0123456789');
    $length=10;
    $site_salt = substr(str_shuffle(str_repeat(CHARACTERS,$length)),0,$length);



    $content = '<h3>Copy/Paste the text below in the config.xml file in the root directory of the roster. When you have properly configure the config.xml file you can advance to <a href="install_step3.php" >the third step of the installation<a></h3>
        <textarea rows="20" cols="75">
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <language_config>
        <language>english</language>
    </language_config>
    <database>
        <dbserver>'.$_POST['dbserver'].'</dbserver>
        <dbname>'.$_POST['dbname'].'</dbname>
        <dbuser>'.$_POST['dbuser'].'</dbuser>
        <dbpassword>'.$_POST['dbpassword'].'</dbpassword>
        <table_prefix>tim</table_prefix>
    </database>
    <roster_root_directory>'.$roster_root_directory.'</roster_root_directory>
    <site_salt>'.$site_salt.'</site_salt>
</config>

</textarea><br/>
<h3></h3>';

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="shortcut icon" type="images/x-icon" href="img/quest_jeton.png" />
    </head>
    <body>
        <h1>INSTALL STEP 2 - Config.xml generator : </h1>

        <?php if (isset($content)) { echo $content; } ?>

        <form METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" onSubmit='return ValidateForm()'>
            <table>
                <tr><td>Data Base Server (if it's your web server just enter 127.0.0.1) :</td><td><INPUT TYPE="TEXT" NAME="dbserver"></td></tr>
                <tr><td>Data Base Name :</td><td><INPUT TYPE="TEXT" NAME="dbname"></td></tr>
                <tr><td>Data Base User Name :</td><td><INPUT TYPE="TEXT" NAME="dbuser"></td></tr>
                <tr><td>Data Base User Password :</td><td><INPUT TYPE="TEXT" NAME="dbpassword"></td></tr>

                <tr><td><center><INPUT type=submit name="submit" VALUE="Generate"></td></tr>
            </table>
        </form>


    </body>
</html>


